#DEFINE vpCrLf CHR(13)+CHR(10)
#DEFINE vpUnicode 5
DECLARE INTEGER CreateDirectory IN kernel32;
		STRING lpPathName, STRING @lpSecurityAttr
		
#DEFINE IMAGE_BITMAP 0
#DEFINE LR_LOADFROMFILE 16
DECLARE INTEGER LoadImage IN user32;
		INTEGER hinst, STRING lpszName, INTEGER uType, ;
		INTEGER cxDesired, INTEGER cyDesired, INTEGER fuLoad
DECLARE INTEGER DeleteObject IN Gdi32;
		INTEGER ho
szSavePath = "C:\Argox"
szSaveFile = "C:\Argox\PPLA_Example.Prn"
sznop1     = "nop_front" + vpCrLf
sznop2     = "nop_middle" + vpCrLf
DECLARE integer A_Bar2d_Maxi in WINPPLA.DLL integer x, integer y, integer primary_Renamed, ;
		integer secondary, integer country, integer service, short mode, integer numeric, ;
		string data_Renamed
DECLARE integer A_Bar2d_Maxi_Ori in WINPPLA.DLL integer x, integer y, integer ori, ;
		integer primary_Renamed, integer secondary, integer country, integer service, short mode, ;
		integer numeric, string data_Renamed
DECLARE integer A_Bar2d_PDF417 in WINPPLA.DLL integer x , integer y, integer narrow, ;
		integer width_Renamed, short normal_Renamed, integer security, integer aspect, ;
		integer row_Renamed, integer column_Renamed, short mode, integer numeric, string data_Renamed
DECLARE integer A_Bar2d_PDF417_Ori in WINPPLA.DLL integer x, integer y, integer ori, integer narrow, ;
		integer width_Renamed, short normal_Renamed, integer security, integer aspect, ;
		integer row_Renamed, integer column_Renamed, short mode, integer numeric, string data_Renamed
DECLARE integer A_Bar2d_DataMatrix in WINPPLA.DLL integer x, integer y, integer rotation, ;
		integer hor_mul, integer ver_mul, integer ECC, integer data_format, integer num_rows, ;
		integer num_col, short mode, integer numeric, string data_Renamed
DECLARE A_Clear_Memory in WINPPLA.DLL
DECLARE A_ClosePrn in WINPPLA.DLL
DECLARE integer A_CreatePrn in WINPPLA.DLL integer selection_Renamed, string filename
DECLARE integer A_Del_Graphic in WINPPLA.DLL integer mem_mode, string graphic
DECLARE integer A_Draw_Box in WINPPLA.DLL short mode, integer x, integer y, integer width_Renamed, ;
		integer height_Renamed, integer top_Renamed, integer side
DECLARE integer A_Draw_Line in WINPPLA.DLL short mode, integer x, integer y, integer width_Renamed, ;
		integer height_Renamed
DECLARE A_Feed_Label in WINPPLA.DLL
DECLARE  string A_Get_DLL_Version in WINPPLA.DLL integer nShowMessage
DECLARE integer A_Get_DLL_VersionA in WINPPLA.DLL integer nShowMessage
DECLARE integer A_Get_Graphic in WINPPLA.DLL integer x, integer y, integer mem_mode, ;
		short format_Renamed, string filename
DECLARE integer A_Get_Graphic_ColorBMP in WINPPLA.DLL integer x, integer y, integer mem_mode, ;
		short format_Renamed, string filename
DECLARE integer A_Get_Graphic_ColorBMPEx in WINPPLA.DLL integer x, integer y, integer nWidth, integer nHeight, ;
		integer rotate, integer mem_mode, short format_Renamed, string id_name, string filename
DECLARE integer A_Get_Graphic_ColorBMP_HBitmap in WINPPLA.DLL integer x, integer y, integer nWidth, integer nHeight, ;
		integer rotate, integer mem_mode, short format_Renamed, string id_name, integer hbm
DECLARE integer A_Initial_Setting in WINPPLA.DLL integer Type_Renamed, string Source
DECLARE integer A_WriteData in WINPPLA.DLL integer IsImmediate, string pbuf, integer length
DECLARE integer A_ReadData in WINPPLA.DLL string @pbuf, integer length, integer dwTimeoutms
DECLARE integer A_Load_Graphic in WINPPLA.DLL integer x, integer y, string graphic_name
DECLARE integer A_Open_ChineseFont in WINPPLA.DLL string path_Renamed
DECLARE integer A_Print_Form in WINPPLA.DLL integer width_Renamed, integer height_Renamed, ;
		integer copies, integer amount, string form_name
DECLARE integer A_Print_Out in WINPPLA.DLL integer width_Renamed, integer height_Renamed, ;
		integer copies, integer amount
DECLARE integer A_Prn_Barcode in WINPPLA.DLL integer x, integer y, integer ori, short type_Renamed, ;
		integer narrow, integer width_Renamed, integer height_Renamed, short mode, integer numeric, ;
		string data_Renamed
DECLARE integer A_Prn_Text in WINPPLA.DLL integer x, integer y, integer ori, integer font_Renamed, ;
		integer type_Renamed, integer hor_factor, integer ver_factor, short mode, integer numeric, ;
		string data_Renamed
DECLARE integer A_Prn_Text_Chinese in WINPPLA.DLL integer x, integer y, integer fonttype, ;
		string id_name, string data_Renamed, integer mem_mode
DECLARE integer A_Prn_Text_TrueType in WINPPLA.DLL integer x, integer y, integer FSize_Renamed, ;
		string FType, integer Fspin, integer FWeight, integer FItalic, integer FUnline, ;
		integer FStrikeOut, string id_name, string data_Renamed, integer mem_mode
DECLARE integer A_Prn_Text_TrueType_W in WINPPLA.DLL integer x, integer y, integer FHeight, ;
		integer FWidth, string FType, integer Fspin, integer FWeight, integer FItalic, integer FUnline, ;
		integer FStrikeOut, string id_name, string data_Renamed, integer mem_mode
DECLARE integer A_Set_Backfeed in WINPPLA.DLL integer back
DECLARE integer A_Set_BMPSave in WINPPLA.DLL integer nSave, string pstrBMPFName
DECLARE integer A_Set_Cutting in WINPPLA.DLL integer cutting
DECLARE integer A_Set_Darkness in WINPPLA.DLL integer heat
DECLARE integer A_Set_DebugDialog in WINPPLA.DLL integer nEnable
DECLARE integer A_Set_Feed in WINPPLA.DLL short rate
DECLARE integer A_Set_Form in WINPPLA.DLL string formfile, string form_name, integer mem_mode
DECLARE integer A_Set_Margin in WINPPLA.DLL integer position, integer margin_Renamed
DECLARE integer A_Set_Prncomport in WINPPLA.DLL integer baud, integer parity, integer data_Renamed, ;
		integer stop
DECLARE integer A_Set_Prncomport_PC in WINPPLA.DLL integer nBaudRate, integer nByteSize, ;
		integer nParity, integer nStopBits, integer nDsr, integer nCts, integer nXonXoff
DECLARE integer A_Set_Sensor_Mode in WINPPLA.DLL short type_Renamed, integer continuous
DECLARE integer A_Set_Speed in WINPPLA.DLL short speed
DECLARE integer A_Set_Syssetting in WINPPLA.DLL integer transfer, integer cut_peel, integer length, ;
		integer zero, integer pause_Renamed
DECLARE integer A_Set_Unit in WINPPLA.DLL short unit
DECLARE integer A_Set_Gap in WINPPLA.DLL integer gap
DECLARE integer A_Set_Logic in WINPPLA.DLL integer logic
DECLARE integer A_Set_ProcessDlg in WINPPLA.DLL integer nShow
DECLARE integer A_Set_ErrorDlg in WINPPLA.DLL integer nShow
DECLARE integer A_Set_LabelVer in WINPPLA.DLL integer centiInch
DECLARE integer A_GetUSBBufferLen in WINPPLA.DLL
DECLARE integer A_EnumUSB in WINPPLA.DLL string @buf
DECLARE integer A_CreateUSBPort in WINPPLA.DLL integer nPort
DECLARE integer A_CreatePort in WINPPLA.DLL integer nPortType, integer nPort, string filename
DECLARE integer A_Clear_MemoryEx in WINPPLA.DLL integer nMode
DECLARE A_Set_Mirror in WINPPLA.DLL
DECLARE integer A_Bar2d_RSS in WINPPLA.DLL integer x, integer y, integer ori, integer ratio, ;
		integer height_Renamed, short rtype, integer mult_Renamed, integer seg, string data1, ;
		string data2
DECLARE integer A_Bar2d_QR_M in WINPPLA.DLL integer x, integer y, integer ori, short mult_Renamed, ;
		integer value_Renamed, integer model, short err, integer mask, short dinput, short mode, ;
		integer numeric, string data_Renamed
DECLARE integer A_Bar2d_QR_A in WINPPLA.DLL integer x, integer y, integer ori, short mult_Renamed, ;
		integer value_Renamed, short mode, integer numeric, string data_Renamed
DECLARE integer A_GetNetPrinterBufferLen in WINPPLA.DLL
DECLARE integer A_EnumNetPrinter in WINPPLA.DLL string @buf
DECLARE integer A_CreateNetPort in WINPPLA.DLL integer nPort
DECLARE integer A_Prn_Text_TrueType_Uni in WINPPLA.DLL integer x, integer y, integer FSize_Renamed, ;
		string FType, integer Fspin, integer FWeight, integer FItalic, integer FUnline, ;
		integer FStrikeOut, string id_name, string data_Renamed, integer format_Renamed, ;
		integer mem_mode
DECLARE integer A_Prn_Text_TrueType_UniB in WINPPLA.DLL integer x, integer y, integer FSize_Renamed, ;
		string FType, integer Fspin, integer FWeight, integer FItalic, integer FUnline, ;
		integer FStrikeOut, string id_name, string data_Renamed, integer format_Renamed, ;
		integer mem_mode
DECLARE integer A_GetUSBDeviceInfo in WINPPLA.DLL integer nPort, string @pDeviceName, ;
		integer @pDeviceNameLen, string @pDevicePath, integer @pDevicePathLen
DECLARE integer A_Set_EncryptionKey in WINPPLA.DLL string encryptionKey
DECLARE integer A_Check_EncryptionKey in WINPPLA.DLL string decodeKey, string encryptionKey, ;
		integer dwTimeoutms
DECLARE integer A_Set_CommTimeout in WINPPLA.DLL integer ReadTotalTimeoutConstant, ;
		integer WriteTotalTimeoutConstant
DECLARE integer A_Get_CommTimeout in WINPPLA.DLL integer @pReadTotalTimeoutConstant, ;
		integer @pWriteTotalTimeoutConstant
DECLARE integer A_Set_LabelForSmartPrint in WINPPLA.DLL integer lablength, ;
		integer gaplength		

MessageBox("Print Label", "PPLA Lib Example")
&& Test code start
&& open port.
PRIVATE nLen, ret, sw
PRIVATE pbuf, ver, strmsg
pbuf = Space(128)

&& dll version.
ver = A_Get_DLL_Version(0)

&& search port.
nLen = A_GetUSBBufferLen() + 1
strmsg = "DLL " + ver + vpCrLf   && only sample coding, not smart.
If nLen > 1
    PRIVATE buf1, buf2
    PRIVATE len1, len2
    len1 = 128
    len2 = 128
    buf1 = Space(len1)
    buf2 = Space(len2)
    A_EnumUSB(@pbuf)
    A_GetUSBDeviceInfo(1, @buf1, @len1, @buf2, @len2)
    sw = 1
    If 1 == sw
       ret = A_CreatePrn(12, buf2)   && open usb.
    Else
       ret = A_CreateUSBPort(1)   && must call A_GetUSBBufferLen() function fisrt.
    EndIf
    If 0 < ret
        strmsg = strmsg + "Open USB fail!"
    Else
        strmsg = strmsg + "Open USB:" + vpCrLf + "Device name: "
        strmsg = strmsg + Left(buf1, len1)
        strmsg = strmsg + vpCrLf + "Device path: "
        strmsg = strmsg + Left(buf2, len2)
        && sw = 2
        If 2 == sw
          && get printer status.
          pbuf = CHR(1) + CHR(70) + CHR(13) + CHR(10)
          A_WriteData(1, pbuf, 4)   && <SOH>F
          ret = A_ReadData(@pbuf, 2, 1000)
        EndIf
    EndIf
Else
    CreateDirectory(szSavePath, null)
    ret = A_CreatePrn(0, szSaveFile)   && open file.
    strmsg = strmsg + "Open " + szSaveFile
    If 0 < ret
        strmsg = strmsg + " file fail!"
    Else
        strmsg = strmsg + " file succeed!"
    EndIf
EndIf
MessageBox(strmsg)
If 0 < ret
    Return
EndIf

&& sample setting.
A_Set_DebugDialog(1)
A_Set_Unit(ASC("n"))
A_Set_Syssetting(1, 0, 0, 0, 0)
A_Set_Darkness(8)
A_Del_Graphic(1, "*")   && delete all picture.
A_Clear_Memory()   && clear memory.
A_WriteData(0, sznop2, Len(sznop2))
A_WriteData(1, sznop1, Len(sznop1))
&& When using standard label, and the printer is Intelli Print mode or Smart Print mode,
&& When calling this function and giving the correct label information,
&& the immediate print function will be enabled according to the label length setting.
A_Set_LabelForSmartPrint(254 * 3, 30)  && abel information: length= 3 * 25.4 mm, gap= 3 mm.
     
&& draw box.
A_Draw_Box(ASC("A"), 10, 10, 380, 280, 4, 4)
A_Draw_Line(ASC("A"), 200, 10, 4, 280)

&& print text, true type text.
A_Prn_Text(20, 30, 1, 2, 0, 1, 1, ASC("N"), 2, "PPLA Lib Example")
A_Prn_Text_TrueType(20, 60, 30, "Arial", 1, 400, 0, 0, 0, "AA", "TrueType Font", 1)   && save in ram.
A_Prn_Text_TrueType_W(20, 90, 20, 20, "Times New Roman", 1, 400, 0, 0, 0, "AB", "TT_W: 多字元測試", 1)

PRIVATE buff1
buff1 = STRCONV("TT_Uni: 多字元測試", vpUnicode)   && Converts double-byte characters to UNICODE(wide characters).
buff1 = buff1 + CHR(0) + CHR(0)   && null.
A_Prn_Text_TrueType_Uni(20, 120, 30, "Times New Roman", 1, 400, 0, 0, 0, "AC", buff1, 1, 1)   && UTF-16

buff1 = CHR(255) + CHR(254)   && UTF-16.
buff1 = buff1 + STRCONV("TT_UniB: 多字元測試", vpUnicode)   && Converts double-byte characters to UNICODE(wide characters).
buff1 = buff1 + CHR(0) + CHR(0)   && null.
A_Prn_Text_TrueType_UniB(20, 150, 30, "Times New Roman", 1, 400, 0, 0, 0, "AD", buff1, 0, 1)   && Byte Order Mark.

&& barcode.
A_Prn_Barcode(220, 60, 1, ASC("A"), 0, 0, 20, ASC("B"), 1, "1234")
A_Bar2d_QR_A(220, 100, 1, Asc("3"), 10, Asc("N"), 0, "QR CODE")

&& picture.
A_Get_Graphic_ColorBMP(220, 150, 1, ASC("B"), "bb.bmp")   && Color bmp file.
A_Get_Graphic_ColorBMPEx(220, 170, 200, 150, 2, 1, ASC("B"), "bb1", "bb.bmp")   && 180 angle.
PRIVATE himage
himage = LoadImage(0, "bb.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)
A_Get_Graphic_ColorBMP_HBitmap(300, 150, 250, 80, 1, 1, ASC("B"), "bb2", himage)   && 90 angle.
If 0 != himage
   DeleteObject(himage)
EndIf

&& output.
A_Print_Out(1, 1, 2, 1)   && copy 2.

&& close port.
A_ClosePrn()

clear dlls